import Queue from "./queue";
import PriorityQueue from "./priorityQueue";
import passGame from "./passGame";


let queue = new Queue();

let pQueue = new PriorityQueue();

// 测试队列
alert("测试队列");

// 在队列中添加元素
alert("在队列中添加元素");

queue.enqueue("abc");
alert(queue.toString());

queue.enqueue("cba");
alert(queue.toString());

queue.enqueue("nba");
alert(queue.toString());

// 查看队列的前端元素
alert("队列的前端元素:" + queue.front());

alert("删除元素");

//从队列中删除元素
queue.dequeue();
alert(queue.toString());

alert("队列中元素个数：" + queue.size());
alert("队列中元素是否为空" + queue.isEmpty());

queue.dequeue();
alert(queue.toString());

queue.dequeue();
alert(queue.toString());

alert("队列中元素是否为空:" + queue.isEmpty());

alert("测试优先级队列");

pQueue.enqueue("abc",10);
alert(pQueue.toString());

pQueue.enqueue("cba",5);
alert(pQueue.toString());

pQueue.enqueue("nba",12);
alert(pQueue.toString());

pQueue.enqueue("mba",3);
alert(pQueue.toString());

alert("队列元素个数：" + pQueue.size());

alert("队列删除");
let size = pQueue.size();
for (let i = 0; i < size;i++){
	let item = pQueue.dequeue();
	alert(item.element + "-" + item.priority);
}

alert("队列是否为空：" + pQueue.isEmpty());

alert("测试击鼓传花游戏");

let names = ["John","Jack","Camila","Ingrid","Carl"];
alert(names + " 5");
let index = passGame(names,5);
alert("最终位置" + index + " " + names[index]);
